<#assign  title="订单确认页面" />
<#assign  index_type=2 />
<#include 'common/header.html' />

<#-- 创建商品基本信息标签 -->
<#assign goodsBaseDataTag= newTag("goodsBaseDataTag") >
<#-- 调用标签获取商品基本信息 -->
<#assign goods= goodsBaseDataTag("'goodsid':${goodsid!0}")>
<#assign goods_id = goods.goods_id />
<#--创建会员信息标签-->
<#assign memberinfoTag = newTag("memberInfoTag") />
<#--调用标签获取会员信息-->
<#assign memberinfo = memberinfoTag()!''>

<input type="hidden" value="1" name="havespec" />
<link rel="stylesheet" href="${ctx}${themes_path}/css/cart.css" type="text/css" />
<link rel="stylesheet" href="${ctx}${themes_path}/css/reveal.css" type="text/css" />
<script src="${ctx}${themes_path}/js/jquery.reveal.js" type="text/javascript"></script>
<style>
    .good_list .title{color:#fff;}
    .insrance{
        font-size: 15px;
    }
</style>
<div class="h-btm">
    <div class="logo">
        <a href="${ctx}/index.html">
            <@image src="${site.logofile!''}" title="logo"/>
        </a>
    </div>
    <div class="flow-steps">
        <span style="font-size: 30px;color: orangered">保单提交界面</span>
    </div>
</div>
<div class="mycar-index">
    <form role="form" action="/app/warranty/web/doAddWarranty.do">
        <div class="insrance" style="margin-left: 15%;margin-right: 15%">
            <span>投保人信息</span><br/>
           <div class="form-group">
               <input type="hidden" value="${goods.goods_id}" id="goods_id" name="goods_id">
               <label for="uname">姓名</label><input type="text" class="form-control" id="uname" name="applicant_name" value="${memberinfo.name}" readonly>
            </div>
            <div class="form-group">
                <label for="umobile">电话</label><input type="text" class="form-control" id="umobile" name="policy_mobile" value="${memberinfo.mobile!''}" placeholder="请输入电话">
            </div>
            <div class="form-group">
                  <label for="uidcard">身份证</label><input type="text" class="form-control" id="uidcard" name="policy_idcard" placeholder="请输入身份证号">
             </div>
             <div class="form-group">
                  <label for="uaddress">住址</label><input type="text" class="form-control" id="uaddress" name="policy_address" value="${memberinfo.address!''}" placeholder="请输入详细住址">
             </div>
            <span>保单信息</span><br/>
            <div class="form-group">
                <label for="insname">被保险人</label><input type="text" class="form-control" id="insname" name="insurant_name" value="茂名养殖场" placeholder="请输入名称" readonly>
            </div>
            <div class="form-group">
                <label for="insname">保险险种</label><input type="text" class="form-control" id="insname" name="insurant_name" value="${goods.name}" placeholder="请输入名称" readonly>
              </div>
            <div class="form-group">
                <label for="name">参保数量</label><input type="text" class="form-control" id="name" name="insured_quantity" value="${num}" readonly>
            </div>
             <div class="form-group">
                    <label for="insprice">保费</label><input type="text" class="form-control" id="insprice" name="premium_amount" value="${goods.price}"  placeholder="请输入名称" readonly>
             </div>
            <div class="form-group">
                <label for="insdate">保单有效期</label><input type="text" class="form-control" id="insdate" name="effective_month" value="${specs}" readonly>个月
            </div>
              <div class="form-group">
                      <label for="insmaxcost">最高保障金额</label><input type="text" class="form-control" id="insmaxcost" name="max_premium_amount" value="${goods.cost}" placeholder="请输入名称" readonly>
              </div>
                <div class="form-group">
                    <span for="havedate">生效日期</span><input type="text" class="form-control" id="havedate" placeholder="以审核时间为准(24小时内)" readonly>
               </div>
            </div>
        <div class="insrance" align="center">阅读<a href="core/admin/apphtml/servicerule.html" >产品条款</a></div>
        <button type="button" class="btn btn-default" onclick="createWarranty()">提交</button>
    </form>
</div>
<!-- 加载促销活动详细浮动层 -->
<div id="myModal" class="reveal-modal">
    <a class="close-reveal-modal">&#215;</a>
    <div class="goods-add-float" style="word-wrap:break-word; word-break:break-all;">
    </div>
</div>
<#include 'common/footer.html'/>

<script type="text/javascript">
    //将数据封装为json数据.
    function GetJson() {
        var json = {
            "goods_id":$("input[name='goods_id']").val(),
            "user_id":10,
            //$("input[name='user_id']").val(),
            "applicant_name":$("input[name='applicant_name']").val(),
            "policy_mobile":$("input[name='policy_mobile']").val(),
            "policy_idcard":$("input[name='policy_idcard']").val(),
            "policy_address":$("input[name='policy_address']").val(),
            "insurant_name":$("input[name='insurant_name']").val(),
            "premium_amount":$("input[name='premium_amount']").val(),
            "max_premium_amount":$("input[name='max_premium_amount']").val(),
            // "begin_time":$("input[name='begin_time']").val(),
            "end_time":$("input[name='end_time']").val(),
            "insured_quantity":$("input[name='insured_quantity']").val(),
            "created_at": "${.now?date}",
            "effective_month":$("input[name='effective_month']").val(),
            "effective_time":$("input[name='effective_time']").val()
        }
        return json;
    }
    //创建保单
    function createWarranty() {
        //检测登陆
            var insured_num = $("input[name='insured_quantity']").val()
            var premium_num = $("input[name='premium_amount']").val()
            var paymoney = insured_num*premium_num
        if($("#uidcard").val()=="" || $("#uidcard").val()==null){
                alert("请输入身份证号码!")
            return
        }
        if($("#uaddress").val()=="" || $("#uaddress").val()==null){
            $("#uaddress").html("请输入详细地址!")
            return
        }
        $.ajax({
            type: "POST",
            url: "/app/warranty/web/addWarranty.do",
            data: {policyInfo:JSON.stringify(GetJson())},
            async: false,
            dataType:"json",
            success: function (data) {
                if(data.result=="1"){
                    window.location.href=
                        "/app/warranty/web/getWarrantyById.do?"
                        + "warrantynumber="+data.number
                        + "&paymoney="+paymoney
                }
                if(data.result=="0"){
                    alert(data.message)
                }
            }
        })
    }
</script>